// pages/order/order.js
import Dialog from '@vant/weapp/dialog/dialog';

Page({

    /**
     * 页面的初始数据
     */
    data: {
      active: 0,
      price: 0,
      show: false
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function () {
      var that = this;
    // 未支付的数据请求
    wx.request({
        url: 'http://localhost:8080/orderCart/findAll',
        method: 'GET',
        success: res => {
          var price1 = 0;
          for (var i = 0; i < res.data.data.length; i++) {
            price1 += parseFloat(res.data.data[i].cuisinePrice)
          }
          console.log(res.data.data)
          that.setData({
            paidList: res.data.data,
            price: price1 * 100
          })
        },
      }), // 已支付的数据请求
      wx.request({
        url: 'http://localhost:8080/orderCart/findLogicDeleted',
        method: 'GET',
        success: res => {
          that.setData({
            unPaidData: res.data.data
          })
        }
      });
      Dialog.alert({
        title: '提示',
        message: '请支付',
        theme: 'round-button',
      }).then(() => {
        // on close
      });
    },
    addprice:function(){
      var p;
      p+=this.data.orderinfo.price;
      return p;
    },
    deleteFood(e){
      console.log(e.currentTarget.dataset.id);
      wx.request({
        url: 'http://localhost:8080/orderCart/deleteByUserId',
        data:{userId : e.currentTarget.dataset.id},
        method: 'GET',
        success: res => {
          console.log(res);
          this.onLoad();
        }
      })
    },
    onSubmit:function(){
      wx.showToast({
        title: "支付成功！"
    });
    }

})